technical_minecraftfandomcom-20200214-history
Tick
Tick encompasses all time wise logic of the game, it is called by the game 20 times per second. These ticks are referred to as game tick and should not be confused with redstone tick, which updates 10 times per second and resembles the speed of a single repeater delay. This is a chronological list of what happens within a single tick, to explain things like why repeaters are always fired before comparators and instant piston logic. Order of updates * Receive packets from all players. * Process all player requests (block placement, removal, toggling, etc.) * Determine what the weather is going to be like. * Spawn wild mobs. * Increment the total world time by 1 (and day time if doDaylightCycle=true). * Tick scheduled updates (repeater delay, unloaded chunks, ...). ** This causes an update chain until everything that can update now is updated. ** Only 1,000 scheduled updates (called tileTicks) can be processed per tick tileTicks created that tick that should be processed in the same tick. * Relight chunks. * Create tileEntities for all blocks that were queued to create tileEntities (most tileEntity blocks, including pistons, don't do this queuing) and don't have tileEntities in them already. * Generate Thunder. * Form Ice and snow. * Send random block updates. * Update player position, collision, send packets to all players (including the one being processed) about a player's position and block modifications. * Village logic. * Village siege. * Portal fixes. * Perform block events until there are none. All block events are processed whenever the next block event processing calls are made (mostly on the same tick; Could be the next tick if caused by entities or tileEntities). Block events could be pistons, beacons, mob spawners and a few other blocks. * Update weather entities. * Update loaded entities and unload if dead. * Every tickable tile entity is updated. ** Old ones are removed. ** New ones are added. * Send out packets to all players. Block updates Block updates occur when it was scheduled or a neighbor has updated and it has been determined a block needs to be re-evaluated. When redstone changes state, all blocks around its neighbors are updated so that a wire can update a torch on the other side of a block. However, the direction change of redstone does not '''cause a block update, allowing vertical BUD switches to be made. A lot of blocks have things happen to them when they are updated: * '''Base Pressure Plate: Update redstone strength. * Bush: Check despawning. * Button: Reset the button (unpowered). ** Wooden buttons are checked for arrows. * Cactus: Grow or pop. * Cocoa: Check valid position and grow if possible. * Command Block: Execute the command. * Crops: Check light and maybe grow. * Dispenser: Dispense an item. * Dragon Egg: Try to fall down. * Liquid: Liquid logic. * Falling: Check if it needs to start to fall. * Farmland: Check to update moisture. * Fire: Try to spread fire. * Grass: Try to spread grass. * Ice: Check for melting. * Leaves: Check leaf decay. * Mushroom: Spread and/or pop. * Mycelium: Spread. * Nether Wart: Try to grow. * Portal: Mob spawning. * Detector Rail: Check for minecarts. * Comparator: Update power. * Repeater: Update power. * Lamp: Check if it needs to turn off. * Ore: Turn off if it was lit. * Redstone Torch: Update power or resolve burned out torch. * Reed: Try to grow. * Sapling: Try to grow. * Snow: Melt if too much light. * Snow block: Drop if too much light. * Stairs: Update stair model. * Lava: Try to spread fire. * Stem: Maybe grow. * Trip Wire: Detect entities. * Trip Wire Hook: Check tripwire state. * Vine: Maybe grow. Random tick A chunk section has random ticks when the chunk is within 128 blocks horizontally of a player. Random ticks will usually update the block, except for Base Pressure Plate, Button, Detector Rail, Repeater, Redstone Torch, Trip Wire and Trip Wire Hook, those will update nothing when randomly ticked. The blocks that are randomly ticked are as follows, with blocks that do nothing when ticked marked in italics. * Base Pressure Plate * Bush * Button * Cactus * Cake * Carpet * Cocoa * Crops * Farmland * Fire * Grass * Ice * Leaves * Liquid * Mushroom * Mycelium * Nether Wart * Portal * Pumpkin * Detector Rail * Redstone Ore * Redstone Torch * Reed * Snow * Snow Block * Static liquid * Stem * Torch * Trip Wire * Trip Wire Hook * Vine Block events * Piston: Will move and cause updates. * Note block: Will make a sound and spawn a particle. Category:Game mechanics